<template>
	<div v-loading="loading">
		<!--    <el-radio-group v-model="form.insidePage" @change="openInsidePageChange">
      <el-radio
        v-for="item in insideLinkSystemPageOptions"
        :key="item.key"
        :label="item.key"
      >{{ item.label }}
      </el-radio>
    </el-radio-group>-->
		<div class="table-container">
			<el-table :data="list" border stripe style="width: 100%" max-height="500" size="small" element-loading-text="加载中" empty-text="暂无数据">
				<el-table-column prop="name" label="功能" />
				<el-table-column prop="description" label="功能描述">
					<template slot-scope="scope">
						<div v-if="scope.row.id === 40">
							{{ scope.row.description }}操作流程可查看
							<span @click="operBtn" class="operBtn">操作详情</span>
						</div>
						<div v-else>{{ scope.row.description }}</div>
					</template>
				</el-table-column>
				<el-table-column label="选择" width="100">
					<template slot-scope="scope">
						<el-radio v-model="form.commonCode" :label="scope.row.code" @change="choose(scope.row)">
							{{ form.commonCode === scope.row.code ? '已选' : '选择' }}
						</el-radio>
					</template>
				</el-table-column>
			</el-table>
		</div>
		<CustomerOperation ref="customerOperationDialog"></CustomerOperation>
	</div>
</template>

<script>
import { getWxappPagesEntrances } from '@/api/wechat';
import CustomerOperation from '../../../../../../components/DialogInsideLink/components/CustomerOperation.vue';
// import wxaBuildConfig from '@/views/wxaBuildModule/config'

export default {
	components: {
		CustomerOperation
	},
	props: {
		row: {
			type: Object
		}
	},
	data() {
		return {
			// 配置
			// insideLinkSystemPageOptions: [],
			// 状态
			loading: false,
			// 数据
			classifyCode: 'DEFAULT',
			form: {
				insidePage: null,
				commonCode: null
			},
			list: []
		};
	},
	computed: {},
	watch: {},
	created() {},
	mounted() {
		// this.insideLinkSystemPageOptions =
		//     wxaBuildConfig[this.classifyCode].insideLinkSystemPage
		// this.form.insidePage = this.row.insidePage
		this.form.commonCode = this.row.insideParams.commonCode;
		this.fetchData();
	},
	methods: {
		/**
		 * 数据组
		 */
		fetchData() {
			this.loadin = true;
			getWxappPagesEntrances()
				.then(res => {
					console.log('list', res);
					this.list = res.data.featureList || [];
				})
				.finally(() => {
					this.loading = false;
				});
		},
		/**
		 * 按钮组
		 */
		//操作详情
		operBtn() {
			this.$refs.customerOperationDialog.open({ roleType: 'wx_kf' });
		},
		// 选择
		choose(row) {
			const params = {
				insidePage: row.name,
				path: row.pagePath,
				mode: 'navigateTo',
				insideParams: {
					insidePageType: 'SYSTEMPAGE',
					commonCode: row.code,
					remark: '站内链接 > 系统页面 > ' + row.name
				}
			};
			this.$emit('selectInsideLink', { type: 'SYSTEMPAGE', params });
		}
		/**
		 * 状态组
		 */
		// openInsidePageChange改变
		// openInsidePageChange(val) {
		//   let params = {}
		//   this.insideLinkSystemPageOptions.some((v) => {
		//     if (this.form.insidePage == v.key) {
		//       params = {
		//         insidePage: v.key,
		//         path: v.openPath,
		//         mode: v.openMode,
		//         insideParams: {
		//           insidePageType: 'SYSTEMPAGE',
		//           remark: '站内链接 > 系统页面 > ' + v.label
		//         }
		//       }
		//       return true
		//     }
		//   })
		//   this.$emit('selectInsideLink', { type: 'SYSTEMPAGE', params })
		// }
		/**
		 * 方法组
		 */
	}
};
</script>
<style rel="stylesheet/scss" lang="scss" scoped>
.el-radio {
	display: block;
	height: 40px;
	line-height: 40px;
}

.el-radio + .el-radio {
	margin-left: 0;
}
.operBtn {
	color: #409eff;
	cursor: pointer;
}
</style>
